﻿//* Write a program that calculates for given N how many trailing zeros present at the end of the number N!. 
//  Examples:
//	N = 10 -> N! = 3628800 -> 2
//	N = 20 -> N! = 2432902008176640000 -> 4
//	Does your program work for N = 50 000?
//	Hint: The trailing zeros in N! are equal to the number of its prime divisors of value 5. Think why!

using System;
using System.Numerics;

class GetFactorialNumberLastTraillingZero
{
    static void Main()
    {
        Console.Write("Enter N = ");
        BigInteger n = BigInteger.Parse(Console.ReadLine());
        
        BigInteger result = 1;
        for (BigInteger i = 1; i <= n; i++)
        {
            result = result * i;
        }

        int lenghtFactorial = result.ToString().Length;
        int lenghtWithoutZero = result.ToString().TrimEnd('0').Length;
        Console.WriteLine("N = {0} -> N! = {1} -> {2}", n, result, lenghtFactorial - lenghtWithoutZero);
    }
}
